const { testsModel } = require('../models/testsModel');

//获取所有试卷信息
module.exports.getTests = async function (req, res, next) {
    //接受前端发送的数据
    const data = req.body;
    // console.log(data);
    const result = await testsModel.find(data);
    // console.log(result);
    if (result) {
        res.send({
            code: 1,
            message: '试卷信息获取成功',
            result: result
        });
    } else {
        res.send({
            code: 0,
            message: '用户信息获取失败'
        })
    }

};

//获取一张试卷信息
module.exports.getOneTests = async function (req, res, next) {
    //接受前端发送的数据
    const data = req.body;

    const result = await testsModel.find(data).populate({
        path: 'typeId exercisesId',
        populate: {
            path: 'pointId'
        }
    });
    if (result) {
        res.send({
            code: 1,
            message: '试卷信息获取成功',
            result: result

        });
    } else {
        res.send({
            code: 0,
            message: '用户信息获取失败'
        })
    }

};
